<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <form th:id="form-data" th:action="@{/news/doEdit}" th:object="${news}" method="post">
                <div class="panel-body">
                    <div class="form-group clear">
                        <label class="col-sm-1 control-label search-label">标题</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="text" class="form-control" th:field="*{title}" maxlength="128" onfocus="clearErrorMsg()" placeholder="请输入标题" />
                        </div>
                        <label class="col-sm-1 control-label search-label">副标题</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="text" class="form-control" th:field="*{subTitle}" maxlength="128" onfocus="clearErrorMsg()" placeholder="请输入副标题" />
                        </div>
                    </div>
                    <div class="form-group clear">
                        <label class="col-sm-1 control-label search-label">简介</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="text" class="form-control" th:field="*{shortDesc}" maxlength="512" onfocus="clearErrorMsg()" placeholder="请输入简介" />
                        </div>
                        <label class="col-sm-1 control-label search-label">外链接</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="text" class="form-control" th:field="*{url}" maxlength="256" onfocus="clearErrorMsg()" placeholder="请输入外链接" />
                        </div>
                    </div>
                    <div class="form-group clear">
                        <label class="col-sm-1 control-label search-label">是否置顶</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="checkbox" th:field="*{isTop}" placeholder="" />
                        </div>
                        <label class="col-sm-1 control-label search-label">新闻类型</label>
                        <div class="col-sm-4 col-sm-inp">
                            <select th:field="*{newsType}" class="form-control code-select" data-clazz="NewsType" data-empty="请选择" data-th-value="*{newsType}">
                            </select>
                        </div>
                    </div>
                    <div class="form-group clear">
                        <label class="col-sm-1 control-label search-label">图片</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="hidden" th:field="*{img}" class="text-input " value=""/>
                            <input style="display: none;" type="file" id="fileUpload" name="fileUpload">
                            <input type="button" class="button" id="upload" onclick="uploadFile();" value="上传">
                            <img id="img-preview" alt="图片预览" style="height: 100px; width: 200px;" th:src="#{system.base.url} + *{img}" />
                        </div>
                    </div>

                    <div class="form-group clear">
                        <label th:for="content" class="col-sm-1 control-label search-label">内容</label>
                        <div style="width: 85%; float: left; margin-left: 15px;">
                            <textarea th:field="*{content}" rows="150" cols="500" th:text="*{content}">

                            </textarea>
                        </div>
                    </div>

                    <div th:if="${editType == 'EDIT'}">
                        <input th:type="hidden" th:field="*{id}" placeholder=""/>
                    </div>
                    <input th:type="hidden" id="editType" name="editType" th:value="${editType}" placeholder="">

                    <div class="clear errorMsg" id="errorMsg"></div>

                    <div class="panel-heading">
                        <div>
                            <button type="button" class="btn btn-sm btn-warning"
                                    th:onclick="'javascript:loadListData(\'' + @{/news/list} + '\')'">返回</button>&emsp;
                            <button type="button" class="btn btn-sm btn-success" onclick="checkParams()">确定</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script th:src="@{/manager/js/news.js}"></script>
<script th:src="@{/common/js/jquery.upload.js}"></script>
<script th:src="@{/manager/js/workOrder.js}"></script>
<script th:src="@{/common/js/misc.js}"></script>
<script th:inline="javascript">
    function uploadFile() {
        upload(function(data) {
            $("#img").val(data);
            $("#img-preview").attr("src", basePath + data);
        }, basePath);
    }

    MiscManager.loadSelect("form-data", basePath + "/select/load");
</script>
</html>
